<?php
$this->setLayout('template'.DS.'default.phtml');

$this->startBlock('topbar');
echo $this->navigation->toHtml();
$this->endBlock();

$this->startBlock();
echo $this->toolbar->toHtml();
echo $this->form->toHtml();
?>
<script language="javascript" type="text/javascript">
$('#recommend_concessions_ids').focus(function(){
	showPoiDialog('<?php echo $this->getUrl(NULL, 'choose-concessions', 'helper', 'customer')?>', 'selectConcessionsFinish', getMultitextValue($(this).attr('id')).join(','));
});
function getMultitextValue(id){
	var result = [];
	var name = $('#' + id).attr('valuename');
	$('input[name="' + name + '"]').each(function(){
		result.push($(this).val());
	});
	return result;
}
function showPoiDialog(url, callback, selected, road, industry){
	url += '/elementid/' + 'recommend_poi_ids';
	if(selected){
		url += '/selected/' + selected
	}
	if(road){
		url += '/roadid/' + road
	}
	if(industry){
		url += '/industryid/' + industry
	}
	$.ajax({
		url:url,
		dataType: 'html',
                method: 'POST',
		success:function(data){
			$('body').append(data);
		}
	});
}
function selectConcessionsFinish(data){
	var texts = [];
	var name = $('#recommend_concessions_ids').attr('valuename');
	$('input[name="' + name + '"]').remove();
	$.each(data, function(index, item){
		texts.push(item.text);
		$('#recommend_concessions_ids').after('<input type="hidden" name="' + name + '" value="' + item.id + '"/>');
	});
	$('#recommend_concessions_ids').val(texts);
}
</script>
<?php
$this->endBlock();